def call(Map config) {
    def robotId = config.robotId
    def status = config.status
    def version = config.version
    def phone = config.phone

    if (!robotId || !status || !version || !phone) {
        echo "Error: Required parameters cannot be empty."
        return
    }
    try {
        wrap([$class: 'BuildUser']) {
            dingtalk(
                    robot: robotId,
                    type: 'ACTION_CARD',
                    title: '构建结果通知',
                    text: [
                            "### ${env.JOB_NAME}",
                            "> - 构建结果：**${status}**",
                            "> - 构建版本：**${version}**",
                            "> - 构建用户：**${env.BUILD_USER}**",
                            "> - 构建号码：**${env.BUILD_NUMBER}**",
                            "> - 持续时间：**${currentBuild.durationString}**",
                            "> - 构建时间：**${env.BUILD_TIMESTAMP}**"
                    ],
                    btns: [
                            [
                                    title: '构建日志',
                                    actionUrl: "${env.BUILD_URL}console"
                            ],
                            [
                                    title: '更改记录',
                                    actionUrl: "${env.BUILD_URL}changes"
                            ]
                    ],
                    at: [phone]
            )
        }
    } catch (Exception e) {
        echo "Error sending DingTalk message: ${e.message}"
    }
}